package monopoly.View;


import java.awt.Color;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.event.MouseListener;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;

import monopoly.Controller.MainFileReader;
import monopoly.Model.Figur;
import monopoly.Model.Spiel;


public class KleinesPlayerPanel extends JPanel {

    private Graphics   g              = null;
    public JLabel      spielerLabel   = null;
    public JLabel      ktoStand       = null;
    private CardDialog CardDialog     = null;
    private Figur      figur          = null;

    public Image       playerImages[] = new Image[4];


    public CardDialog getCardDialog() {
        if ( CardDialog == null ) {
            CardDialog = new CardDialog();
        }
        return CardDialog;
    }

    public void updatePanel(Figur figur){
    	this.figur = figur;
    	this.repaint();
    }
    public JLabel getKtoStand() {
    	if (ktoStand==null) {
    		ktoStand = new JLabel( "00000" );
    		ktoStand.setSize( 50, 15 );
    		ktoStand.setBackground( Color.red );
    		ktoStand.setLocation( 160, 30 );
    	}
        return ktoStand;
    }

    public JLabel getSpielerLabel() {
        return spielerLabel;
    }

    public void setKtoStand(String ktoStand ) {
    	getKtoStand().setText( ktoStand);
    }

    public void setSpielerLabel( JLabel spielerLabel ) {
        this.spielerLabel = spielerLabel;
    }

    public KleinesPlayerPanel( Figur figur, int position ) {

      
        this.figur = figur;
    

        playerImages = MediaFiles.getMediaFile().getFiguren();

       // this.setLayout( null );
        /** vorher: GridBagLayout */
        this.setBounds( new Rectangle( 19, position, 225, 70 ) );
        this.setBorder( BorderFactory.createLineBorder(Color.BLACK));
        //this.add( getKtoStand() );
        // addMouseListener( this );

    }

    public void paintComponent( Graphics g ) {
        /** Spieler Icon */
        g.drawString(figur.getKontostand()+"",150, 40);
        g.drawString(figur.getName()+"",100 ,40 );
        g.setColor( Color.BLACK );
        g.drawImage(  playerImages[figur.getId()], 10,20,this );

    }
}
